/*
 * SequentialCore.h
 *
 *  Created on: Oct 18, 2012
 *      Author: David Kadlecek, Ales Fiser
 */

#ifndef SEQUENTIALCORE_H_
#define SEQUENTIALCORE_H_

#include "general.h"
#include "InputMatrixHolder.h"
#include "Task.h"

class ParallelCore {
private:
	int maxdepth, maxResultDepthGlobal;
	int16_t *maxresult;
	InputMatrixHolder* inputMatrix;
	Task* task;

	short isConnected(int node1, int node2);
	void checkAndSaveMaximum(Task* task);
	short isNotReasonToContinue();
	void logPrintNodesNotConnected(int node1, int node2);
	void doOneSolvingStep();
	void workFinishAskForNew();
	void sendTokenToNext(int isTokenDirty);
	bool isHerePointToTryThisBranch();
	void tokenRecieved();
	void findClique();
	void sendMyBestResultTo0();
	void sendMyBestResultDepthToOthers();
	void mergeMaxResults(int flag);

public:
	ParallelCore();
	int16_t* doParallel(double r_p);
	void loadInputMatrix(InputMatrixHolder* inputMatrix);
	virtual ~ParallelCore();
	short isPossibleClique(int16_t* candidate, int sizeOfCandidate);
};

#endif /* SEQUENTIALCORE_H_ */
